// 返回防抖函数
export function debounce(func: (...args: any[]) => void, wait: number): (...args: any[]) => void {
  let timeoutId: number | null

  return (...args: any[]) => {
    const later = () => {
      timeoutId = null
      func(...args)
    }

    if (timeoutId) {
      clearTimeout(timeoutId)
    }

    timeoutId = setTimeout(later, wait)
  }
}
